package com.autumn.config.client.consumer.controllers;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.autumn.config.api.CloudConfigService;
import com.autumn.config.api.vo.ServiceProfileInfo;
import com.autumn.config.api.vo.ServiceProfileValue;
import com.autumn.scheduler.api.services.AutumnJobService;
import com.autumn.scheduler.api.services.dto.output.AutumnJobDetailsOutput;

import io.swagger.annotations.Api;

@RestController
@RequestMapping("/demo/config")
@Api(tags = "Config Test 客户端")
public class ConfigTestController {

	@Reference
	private CloudConfigService configService;

	@Reference
	private AutumnJobService schedulerService;

	@PostMapping("/serviceProfile")
	public ServiceProfileInfo getServiceProfile(@RequestBody ServiceProfileValue profile) {
		return configService.serviceProfile(profile);
	}

	@GetMapping("/getJob")
	public AutumnJobDetailsOutput getServiceProfile(long id) {
		return schedulerService.getJob(id);
	}

}
